package com.eastfair.rocketmq;


import cn.hutool.core.collection.CollectionUtil;
import com.eastfair.point.PointKeyDefinition;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 单事件mq信息
 */
public class SelectorExpressionTopicOfBusiness {
    /**
     * auth服务
     */
    public static List<String> authTopicTagOfBusiness = Arrays.asList(
            PointKeyDefinition.LOAD_USER_PERMISS,
            PointKeyDefinition.LOAD_USER_PERMISS_OF_ORG,
            PointKeyDefinition.LOAD_USER_PERMISS_OF_ROLE,
            "auth_loadUserPermissOfOrg",
            "auth_loadUserPermissOfRole",
            PointKeyDefinition.UPD_USER_DETAIL,
            PointKeyDefinition.MESSAGE_READY_SEND_POINT,
            PointKeyDefinition.MESSAGE_SEND_POINT
    );


    /**
     * 单事件服务
     * gatewy服务
     */
    public static List<String> gatewayTopicTagOfBusiness = Arrays.asList(
            PointKeyDefinition.GATEWAY_BLACK
    );


    public static String queryStr(String mqSystem, List<String> list) {
        List<String> mqList = list.stream().filter(s -> s.indexOf(mqSystem + "_") > -1).collect(Collectors.toList());
        StringBuilder stringBuilder = new StringBuilder();
        if (CollectionUtil.isEmpty(mqList)) {
            return null;
        }
        mqList.stream().forEach(s -> stringBuilder.append(s).append("||"));
        return stringBuilder.toString().substring(0, stringBuilder.length() - 2);
    }
}
